package com.huicoo.forestmanager.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

public class PatrolRecordAdapter extends FragmentPagerAdapter {
    ArrayList<String> mTitles = new ArrayList<>();//片段的集合.内容让外界添加
    ArrayList<Fragment> mFragments = new ArrayList<>();//片段的集合.内容让外界添加

    public PatrolRecordAdapter(FragmentManager fm) {
        super(fm);
    }

    /**
     * 添加一页
     *
     * @param fragment
     */
    public void addFragmentPager(String titles,Fragment fragment) {//给外界提供添加方法
        mFragments.add(fragment);
        mTitles.add(titles);

    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override//标签布局-->获取页面标题
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position);
    }
}